﻿using AviewLightSource;
using FinalTestMachine.Connect;
using FinalTestMachine.Motion.IO;
using FinalTestMachine.Motion.Product;
using RM_dll2.IoCylinder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FinalTestMachine.Motion.Process
{
    /// <summary>
    /// 工位3测试
    /// </summary>
    public class ThirdTestStation : Process_TestStationBase
    {
        public static readonly ThirdTestStation Cur = new ThirdTestStation();

        private ThirdTestStation() : base(SiteConnectManager.Cur.GetCommunicationHelper(3), "工位三", 2)
        {
        }

        public static ThirdTestStation CreateInstance()
        {
            return Cur;
        }

        public override bool AxiOrCylinderToWorkPos()
        {
            if (!StaticIOHelper.Cylinder_SiteBowlLightUpDown.WorkPos(out CyErrInfo))
            {
                WriteErrToUser(CyErrInfo);
                return false;
            }

            /*if (!SiteConnectManager.Cur.SetVolToStation3(OtherParamHelper.Cur.CheckVol.GetValue))
            {
                WriteErrToUser($"开始测试前将电压设为{OtherParamHelper.Cur.CheckVol.GetValue}V失败！请检查与程控电源通讯！");
                return false;
            }*/
            return true;
        }

        public override bool AxiOrCylinderToWaitPos()
        {
            /*if (!Connect.SiteConnectManager.Cur.SetVolToStation3(OtherParamHelper.Cur.TestVol.GetValue))
            {
                WriteErrToUser($"测试结束将电压设为{OtherParamHelper.Cur.TestVol.GetValue}V失败！请检查与程控电源通讯！");
                return false;
            }*/

            if (!StaticIOHelper.Cylinder_SiteBowlLightUpDown.OriginPos(out CyErrInfo))
            {
                WriteErrToUser(CyErrInfo);
                return false;
            }
            return true;
        }

        public override bool OtherActionBeforeExit()
        {
            return true;
        }

        public override ProductTestStation GetCurrentStation()
        {
            return CurrentProduct?.GetTestStation(3);
        }

        public override ProductTestStation GetLastStation()
        {
            return CurrentProduct?.GetTestStation(2);
        }
    }
}